package tests;

import static org.junit.Assert.*;

import java.util.Random;

import game.Dice;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Before;
import org.junit.Test;

public class DiceTest {
	Random random;
	Dice dice;
	
	@Before
	public void doBefore()
	{
		random = mock(Random.class);
		dice = new Dice(random);
	}
	
	@Test
	public void testRollADice() {				
		when(random.nextInt()).thenReturn(1);	
		
		dice.rollDice();
		assertTrue( 1 <= dice.getNumber() && dice.getNumber() <= 6 );
	}
	
	@Test
	public void testRollTwoDice() {
		int n1, n2;
		
		when(random.nextInt(6)).thenReturn(1).thenReturn(5);
		dice.rollDice();
		n1 = dice.getNumber();
		dice.rollDice();
		n2 = dice.getNumber();
		assertTrue( n1 != n2 );
	}
}
